package C;

import java.util.Scanner;

public class C36 {
    static class TreeNode {
        int val;
        int height;
        TreeNode left;
        TreeNode mid;
        TreeNode right;

        public TreeNode(int val) {
            this.val = val;
        }
    }

    static class Tree {
        TreeNode root;
        int height;

        public int add(int val) {
            TreeNode node = new TreeNode(val);
            if (this.root==null) {
                node.height=1;
                this.root = node;
                this.height=1;
            } else {
                TreeNode cur = this.root;
                TreeNode pre = new TreeNode(0);
                node.height = 1;
                int flag = 0;
                while(cur!=null) {
                    pre = cur;
                    if (val<cur.val-500) {
                        cur = cur.left;
                        flag = 1;
                    } else if (val>cur.val+500) {
                        cur = cur.right;
                        flag = 3;
                    } else {
                        cur = cur.mid;
                        flag = 2;
                    }
                    node.height++;
                }
                if (flag == 1) {
                    pre.left = node;
                } else if (flag == 2) {
                    pre.mid = node;
                } else {
                    pre.right = node;
                }
                this.height = Math.max(this.height,node.height);
            }
            return this.height;
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Tree tree = new Tree();
        for (int i=0;i<n;i++) {
            int val = sc.nextInt();
            tree.add(val);
        }
        System.out.println(tree.height);
    }
}
